﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace Manager
{
    public partial class AddCT : Form
    {
        SQL sql = new SQL();
        public AddCT()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {  
            string query = "sql_insert_CongTrinh";
            SqlParameter[] pr = new SqlParameter[6];
            pr[0] = new SqlParameter("@MCT", textBox1.Text);
            pr[1] = new SqlParameter("@NAMECT", textBox2.Text);
            pr[2] = new SqlParameter("@MPB", comboBox1.Text);
            pr[3] = new SqlParameter("@DATECP", dateTimePicker1.Value.ToShortDateString());
            pr[4] = new SqlParameter("@DATEKC", dateTimePicker2.Value.ToShortDateString());
            pr[5] = new SqlParameter("@DATEHT", dateTimePicker3.Value.ToShortDateString());

            if (textBox1.Text == "" || textBox2.Text == "" || comboBox1.Text == "")
            {
                MessageBox.Show("Hay nhap day du thong tin cong trinh");
            }
            else
            {
                sql.execute_Query(query, pr);
                MessageBox.Show("success");
                this.Close();
            }





        }

        private void getMPB()
        {
            string query = "sql_MPB_cb";
            comboBox1.DataSource= sql.getDataTable(query);
            comboBox1.ValueMember = "MPB";
            comboBox1.Text = "";

        }

        private void AddCT_Load(object sender, EventArgs e)
        {
            getMPB();
        }
    }
}
